Arrays in Bash

http://stackoverflow.com/questions/1527049/bash-join-elements-of-an-array

FOO=( a b c )
SAVE_IFS=$IFS
IFS=","
FOOJOIN="${FOO[*]}"
IFS=$SAVE_IFS
echo $FOOJOIN
#/!bin/bash
foo=('foo bar' 'foo baz' 'bar baz')
bar=$(printf ",%s" "${foo[@]}")
bar=${bar:1}
echo $bar

reference: The Ultimate Bash Array Tutorial with 15 Examples

Homepage
Comments

Hide Comments